package com.wcx.create.singleton;

/**
 * 项目: design-pattern-githupdemo
 * <p>
 * 功能描述: 懒汉模式
 *
 * @author: WuChengXing
 * @create: 2021-01-11 23:10
 **/
public class LazyManSingleton {
    private static LazyManSingleton instance = null;

    private LazyManSingleton() {
    }

    /**
     * 这种方式会出现线程不安全的现象，无法保证对象只被初始化一次
     * @return
     */
    public static LazyManSingleton getInstance() {
        if (instance == null) {
            instance = new LazyManSingleton();
        }
        return instance;
    }

}
